package com.fjwt.gz.mgr.ctrl.realnameauth;

import cn.hutool.db.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fjwt.gz.core.exception.BizException;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.dto.FansAuthDTO;
import com.fjwt.gz.db.vo.FansAuthVO;
import com.fjwt.gz.mgr.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.FansAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("/api/realName")
public class RealNameAuthController extends CommonCtrl {
    @Autowired
    private FansAuthService fansAuthService;

    @PreAuthorize("hasAnyAuthority('ENT_DATA_REPORT_REAL_NAME_INFO')")
    @PostMapping("/list")
    public ApiRes realNameAuth() {
        FansAuthDTO fansAuthDTO = getObject(FansAuthDTO.class);
        IPage<FansAuthVO> fansAuthVO = fansAuthService.realNameAuth(getIPage(),fansAuthDTO);
        return ApiRes.ok(fansAuthVO);
    }

    @PreAuthorize("hasAnyAuthority('ENT_DATA_REPORT_REAL_NAME_INFO_EXPT')")
    @PostMapping("/exportRealAward")
    public ApiRes exportRealAward() {
        FansAuthDTO fansAuthDTO = getObject(FansAuthDTO.class);
        log.info("运营端导出活动报表，请求地址：/api/realName/exportRealAward，请求参数：fansAuthDTO:{}", fansAuthDTO);
        if (fansAuthDTO ==  null) {
            throw new BizException("请求参数缺失！");
        }
        return fansAuthService.exportReal(fansAuthDTO, getCurrentUser().getSysUser());
    }



}
